<template>
  <div class="custom_right_menu">
    <!-- 
    <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
      <el-radio-button :label="false">展开</el-radio-button>
      <el-radio-button :label="true">收起</el-radio-button>
    </el-radio-group> -->
    <el-menu
      default-active="1-1"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      @select="selectHandle"
      :collapse="collapse"
    >
      <el-submenu
        :index="menu.index"
        v-for="(menu, index) in menuData.data"
        :key="'menu_index_' + index"
      >
        <template #title>
          <i :class="menu.icon"></i>
          <span>{{ menu.title }}</span>
        </template>
        <el-menu-item-group
          v-for="(smenu, sindex) in menu.data"
          :key="'smenu_index_' + sindex"
        >
          <template #title>
            {{ smenu.title }}
          </template>
          <el-menu-item
            :index="smenu.index"
            v-for="(smenuItem, siIndex) in smenu.data"
            :key="'smenuItem_index_' + siIndex"
            :data-router="smenuItem.router"
            :data-index="smenu.index"
            :data-title="smenuItem.title"
          >
            {{ smenuItem.title }}
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
export default {
  props: {
    collapse: {
      type: Boolean,
      default() {
        return false;
      },
    },
    menuData: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {};
  },
  methods: {
    handleOpen(v) {
      console.log(v);
    },
    handleClose(v) {
      console.log(v);
    },
    selectHandle() {
      //console.log(arguments[2].$el);
      this.$emit("addTabHandle", {
        title: arguments[2].$el.dataset.title,
        router: arguments[2].$el.dataset.router,
      });
    },
  },
};
</script>
<style lang="less">
.custom_right_menu {
  flex: 1;
  .el-menu {
    height: 100%;
  }
}
</style>
